package com.glory.brepda.activity.mfg;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.RecyclerView;
import com.glory.brepda.R;
import com.glory.brepda.adapter.newScrapListAdapter;
import com.glory.brepda.base.BaseActivity;
import com.glory.brepda.callback.CustomDialogEntityCallBack;
import com.glory.brepda.entity.DefectCodeEntity;
import com.glory.brepda.entity.EDCListBean;
import com.glory.brepda.entity.LotInfoEntity;
import com.glory.brepda.entity.LotLists;
import com.glory.brepda.entity.LotactionLists;
import com.glory.brepda.entity.ScrapEntity;
import com.glory.brepda.entity.response.BaseResponseBean;
import com.glory.brepda.utils.LotUtils;
import com.glory.brepda.utils.NetUtils;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.model.Response;
import com.pda.platform.ui.ui_pdaplatform.callback.FreeUI_DialogEntityCallBack;
import com.pda.platform.ui.ui_pdaplatform.callback.FreeUI_EntityCallBack;
import com.pda.platform.ui.ui_pdaplatform.dialog.FreeUI_GeneralFragmentDialog;
import com.pda.platform.ui.ui_pdaplatform.dialog.FreeUI_GeneralPop;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_DialogUtils;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_LogUtils;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_PopUtils;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_ToastUtils;
import com.pda.platform.ui.ui_pdaplatform.view.FreeUI_ClearEditText;

import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;

import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class WorkEnd3Activity extends BaseActivity {

    @BindView(R.id.tvTitle)
    TextView tvTitle;
    @BindView(R.id.tvBaseSubmit)
    TextView tvBaseSubmit;
    @BindView(R.id.tvSearch) //搜索按钮
    TextView tvSearch;
    @BindView(R.id.tvAdd) //添加按钮
    TextView tvAdd;
    @BindView(R.id.llMain)
    LinearLayout llMain;
    @BindView(R.id.llScrapList)
    LinearLayout llDefectList;
    @BindView(R.id.rvScrapList)
    RecyclerView rvScrapList;
    @BindView(R.id.etLot)
    TextView etLot;
    @BindView(R.id.tvTrackInNum)
    TextView tvTrackInNum;
    @BindView(R.id.scrapNumSum)
    TextView scrapNumSum;
    @BindView(R.id.scrapPpmSum)
    TextView scrapPpmSum;
    @BindView(R.id.tvTrackOutNum)
    TextView tvTrackOutNum;
    @BindView(R.id.tvLotYield)
    TextView tvLotYield;
    @BindView(R.id.tvOrderYield)
    TextView tvOrderYield;
    @BindView(R.id.orderScrapNumSum)
    TextView orderScrapNumSum;
    @BindView(R.id.tvLotTotalYield)
    TextView tvLotTotalYield;
    @BindView(R.id.flScrapList)
    FrameLayout flScrapList;
    @BindView(R.id.ivScrapArrow)
    ImageView ivScrapArrow;
    @BindView(R.id.tvScrapCode)
    FreeUI_ClearEditText tvScrapCode;
    @BindView(R.id.etInputScrapNum)
    FreeUI_ClearEditText etInputScrapNum;
    @BindView(R.id.tvtMatCount)
    TextView tvtMatCount;
    @BindView(R.id.etaMatCount)
    FreeUI_ClearEditText etaMatCount;
    private List<String> scrapCodeList = new ArrayList<>();
    private List<String> searchScrapCodeList = scrapCodeList;
    private String lotID;
    private String eqpID;
    private String scrapCodeSRCNUM;
    private String scrapCode;
    private String trackOutNum;
    private List<String> list;
    private LotInfoEntity lotInfoEntity;
    private List<ScrapEntity> scrapList;
    private newScrapListAdapter scrapListAdapter;
    private String method;
    private String title;
    private String scan;
    private String thinning = "";
    private String totalNumber = "";
    private String activity;
    private String TRACKINQTY = "";
    private FreeUI_GeneralPop scrapCodePop;
    private String orderScrapNum = "0";
    private String orderMainQty = "0";
    private String lotTotalScrap = "0";
    private String TRACKOUTQTY = "";
    Integer aMatCount = 0;
    Integer tMatCount = 0;
    @Override
    protected int getLayoutResId() {
        return R.layout.activity_work_end_3;
    }

    @Override
    protected void initData() {
        getScrapInfo();

    }

    @Override
    protected void initView() {
        setMainLayout(llMain);
        initRecyclerView(rvScrapList, this);
        Bundle bundle = getIntent().getExtras();
        lotInfoEntity = (LotInfoEntity) bundle.getSerializable("LOTINFOENTITY");
        scrapList = (List<ScrapEntity>) bundle.getSerializable("ScrapList");

        list = bundle.getStringArrayList("MATERIELMODELLIST");
        lotID = bundle.getString("LOTID");
        eqpID = bundle.getString("EQPID");
        method = bundle.getString("method");
        title = bundle.getString("title");
        scan = bundle.getString("scan");
        thinning = bundle.getString("THINNING");
        totalNumber = bundle.getString("TOTALNUMBER");
        activity = bundle.getString("activity");
        TRACKINQTY = bundle.getString("TRACKOUTNUM");
        scan = scan == null ? "" : scan;
        tvTitle.setText(title);
        TRACKOUTQTY = bundle.getString("TRACKOUTQTY");
        scrapCodeSRCNUM = bundle.getString("SCRAPCODESRC");
        scrapCode = bundle.getString("DEFECTCODE");
        trackOutNum = bundle.getString("TRACKOUTNUM");
        orderScrapNum = bundle.getString("orderScrapNum");
        orderMainQty = bundle.getString("orderMainQty");
        lotTotalScrap = bundle.getString("lotTotalScrap");
//        aMatCount = Integer.parseInt(bundle.getString("aMatCount"));
        etaMatCount.setText(bundle.getString("aMatCount"));
        tvtMatCount.setText(bundle.getString("aMatCount"));
        etLot.setText(lotID);
        tvTrackInNum.setText(TRACKINQTY);
        tvTrackOutNum.setText(TRACKINQTY);
        scrapListAdapter = new newScrapListAdapter(null, tvTrackOutNum,tvLotYield,tvOrderYield,scrapNumSum,orderScrapNumSum,scrapPpmSum,tvLotTotalYield,TRACKINQTY,Integer.parseInt(orderScrapNum),Integer.parseInt(orderMainQty),Integer.parseInt(lotTotalScrap));
        rvScrapList.setAdapter(scrapListAdapter);
        tvLotYield.setText(calculateYield(0));
        tvOrderYield.setText(calculateOrderYield(0));
        tvLotTotalYield.setText(calculateLotYield(0));
        orderScrapNumSum.setText(calculateOrderScrapNum());
        tvScrapCode.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                // 在文本改变后调用
                if (s.length() ==0) {
                    searchScrapCodeList=scrapCodeList;
                }

            }
        });
    }

    private String calculateLotYield(int scrapNum) {
        double tin = Double.valueOf(tvTrackInNum.getText().toString());
        double totalScrap = Double.valueOf(lotTotalScrap);
        double result = (tin-scrapNum)/(tin+totalScrap)*100;
        String formatResult = String.format("%.2f",result)+"%";
        return formatResult;
    }

    private String calculateOrderYield(int scrapNum) {
        double omq = Double.valueOf(orderMainQty);
        double totalScrapNum = scrapNum+Double.valueOf(orderScrapNum);
        double result = (omq-totalScrapNum)/omq*100;
        String formatResult = String.format("%.2f",result)+"%";
        return formatResult;
    }

    private String calculateYield(int scrapNum) {
        //出站数/进站数
        double tin = Double.valueOf(tvTrackInNum.getText().toString());
        double result = (tin-scrapNum)/tin*100;
        String formatResult = String.format("%.2f",result)+"%";
        return formatResult;
    }



    @OnClick({R.id.tvBaseSubmit,R.id.ivScrapArrow,R.id.tvSearch,R.id.tvAdd})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tvBaseSubmit: //提交按钮逻辑

                //某些工步可能不需要填排数 如果理论值为空，则可以不填写排数信息
                if(!StringUtils.isBlank(tvtMatCount.getText().toString())){
                    if (StringUtils.isBlank(getText(etaMatCount))){
                        showConfirmDialog("请输入出站排数");
                        return;
                    }
                    aMatCount = Integer.parseInt(getText(etaMatCount));
                    tMatCount = Integer.parseInt(tvtMatCount.getText().toString());
                    if(tMatCount.compareTo(aMatCount)<0){
                        showConfirmDialog("出站排数不允许大于进站排数");
                        return;
                    }
                    //TODO 校验排数填写是否合理
                }

                lotDAWBTrackOut(this, method, getSupportFragmentManager(), "", eqpID,
                        lotID, new ArrayList<ScrapEntity>(), list, scrapNumSum.getText().toString(), lotInfoEntity.getLOT().getMAINQTY(), lotInfoEntity,
                        0, String.valueOf(Integer.parseInt(TRACKINQTY)-Integer.parseInt(scrapNumSum.getText().toString())), new ArrayList<EDCListBean.ListBean>(), new LotUtils.netCallback() {
                            @Override
                            public void onSuccess(Object response) {

                                Intent intent = new Intent();
                                setResult(1, intent);
                                finish();
                            }

                            @Override
                            public void onFail(Throwable t) {

                            }
                        });
                break;
            case R.id.ivScrapArrow: //下拉框按钮逻辑
                scrapCodePop = FreeApi_PopUtils.getNormalPop(getApplicationContext(), flScrapList.getWidth(), searchScrapCodeList, ivScrapArrow, (codeS, i) -> {
                    tvScrapCode.setText(codeS);
                });
                FreeApi_PopUtils.setArrowShow(ivScrapArrow);
                scrapCodePop.showAsDropDown(flScrapList, 0, 0);
                break;
            case R.id.tvSearch: //搜索按钮逻辑
                searchScrapCodeList = filterScrapCode(getText(tvScrapCode));
                if (searchScrapCodeList.isEmpty()){
                    showToast("没有对应项目",false);
                    return;
                }else{
                    tvScrapCode.setText(searchScrapCodeList.get(0));
                }
                break;
            case R.id.tvAdd: //添加按钮逻辑

                if("".equals(getText(etInputScrapNum)) || Integer.parseInt(getText(etInputScrapNum))<=0){
                    showToast("请输入正确的数量",false);
                    return;
                }
                if(!scrapCodeList.contains(getText(tvScrapCode))){
                    showToast("报废项" + getText(tvScrapCode) + "不存在",false);
                    searchScrapCodeList=scrapCodeList;
                    return;
                }
                ScrapEntity scrapEntity = new ScrapEntity();
                scrapEntity.setACTIONCODE(tvScrapCode.getText().toString().split("/")[0]);
                scrapEntity.setACTIONREASON(tvScrapCode.getText().toString().split("/")[1]);
                scrapEntity.setLOTID(lotInfoEntity.getLOT().getLOTID());
                scrapEntity.setLOTRRN(lotInfoEntity.getLOT().getOBJECTRRN());
                scrapEntity.setMAINQTY(getText(etInputScrapNum).toString());
                scrapEntity.setSUBQTY(getText(etInputScrapNum).toString());
                scrapEntity.setACTIONTYPE("Scrap");
                scrapEntity.setScrapNum(getText(etInputScrapNum).toString());
                scrapEntity.setPpm(calculatePpm(getText(etInputScrapNum).toString(),TRACKINQTY));

                int numSum = 0;
                double ppmSum = 0;
                for (int i = 0; i < scrapListAdapter.getData().size(); i++) {
                    numSum+=Integer.parseInt(scrapListAdapter.getData().get(i).getScrapNum());
                    ppmSum+=Double.valueOf(scrapListAdapter.getData().get(i).getPpm());
                }
                if (numSum+Integer.parseInt(scrapEntity.getScrapNum())>Double.valueOf(tvTrackInNum.getText().toString())){
                    showToast("合计报废数不可大于进站数",false);
                    return;
                }
                if (scrapListAdapter.getData().size() > 0) {
                    if (containCode(scrapEntity)) {
                        scrapListAdapter.addData(scrapEntity);
                    }else {
                        return;
                    }
                } else {
                    scrapListAdapter.addData(scrapEntity);
                }
                numSum+=Integer.parseInt(scrapEntity.getScrapNum());
                ppmSum+=Double.valueOf(scrapEntity.getPpm());

                scrapNumSum.setText(Integer.toString(numSum));
                scrapPpmSum.setText(String.format("%.2f",ppmSum));
                tvLotYield.setText(calculateYield(numSum));
                orderScrapNumSum.setText(calculateOrderScrapNum());
                tvOrderYield.setText(calculateOrderYield(numSum));
                tvLotTotalYield.setText(calculateLotYield(numSum));
                etInputScrapNum.setText("");
                break;
        }
    }

    private String calculateOrderScrapNum() {
        int result = Integer.parseInt(scrapNumSum.getText().toString())+Integer.parseInt(orderScrapNum);
        return result+"";
    }

    private List<String> filterScrapCode(String code) {
        List<String> targetList = new ArrayList<>();
        if(!code.equals("")){
            for (int i = 0; i < scrapCodeList.size(); i++) {
                if (scrapCodeList.get(i).contains(code)){
                    targetList.add(scrapCodeList.get(i));
                }
            }
            return targetList;
        }else{
            return scrapCodeList;
        }

    }

    private void getScrapInfo() {
        FreeUI_EntityCallBack<BaseResponseBean<DefectCodeEntity>> callback = new FreeUI_DialogEntityCallBack<BaseResponseBean<DefectCodeEntity>>
                (new TypeToken<BaseResponseBean<DefectCodeEntity>>() {
                }.getType(), getSupportFragmentManager(), this) {

            @Override
            public void onSuccess(Response<BaseResponseBean<DefectCodeEntity>> response) {
                super.onSuccess(response);
                if (response.body().isSuccess(getApplicationContext(), true, getSupportFragmentManager())) {
                    scrapCodeList.clear();
                    List<DefectCodeEntity.DefectCode> scrapcodelists = response.body().getResponse().getBody().getADREFLIST();
                    for (DefectCodeEntity.DefectCode code : scrapcodelists) {
                        scrapCodeList.add(code.getKEY() + "/" + code.getDESCRIPTION());
                        ScrapEntity scrapEntity = new ScrapEntity();
                        scrapEntity.setACTIONCODE(code.getKEY());
                        scrapEntity.setACTIONREASON(code.getDESCRIPTION());
                        scrapEntity.setLOTID(lotInfoEntity.getLOT().getLOTID());
                        scrapEntity.setLOTRRN(lotInfoEntity.getLOT().getOBJECTRRN());
                        scrapEntity.setACTIONTYPE("Scrap");
                        scrapEntity.setSUBQTY("");
                    }

                }
            }

            @Override
            public void onError(Response<BaseResponseBean<DefectCodeEntity>> response) {
                super.onError(response);
                loadError(response.getException(), "GETSTEPBYLOT");
            }
        };
        JsonObject map = new JsonObject();
        map.addProperty("REFERENCENAME", lotInfoEntity.getSTEPLIST().get(0).getSCRAPCODESRC());
        map.addProperty("REFERENCETYPE", "USER");
        NetUtils.requestPostNet("IF.ADREFLISTQUERY", "Common", WorkEnd3Activity.this, map, callback);
    }



    private String calculatePpm(String num,String mainNum) {
        Double qty = Double.valueOf(num);
        Double mainQty = Double.valueOf(mainNum);
        Double ppm = (qty/mainQty)*1000000;
        String temp =String.valueOf(ppm);
        String temp2 = String.format("%.2f",ppm);
        return temp2;
    }

    private boolean containCode(ScrapEntity scrapEntity) {
        for (ScrapEntity bean : scrapListAdapter.getData()) {
            if (bean.getACTIONCODE().equals(scrapEntity.getACTIONCODE())) {
                showToast("列表中已有当前报废项!", false);
                return false;
            }
        }
        return true;
    }

    private void lotDAWBTrackOut(Activity context, String method, FragmentManager fragmentManager, String storageid, String eqpWork, String lotID,
                                 List<ScrapEntity> defectData, List<String> carrierList, String scrapNum, String subqty, LotInfoEntity lotInfoEntity,
                                 int defectNum, String trackNum, List<EDCListBean.ListBean> edcList, LotUtils.netCallback callback) {

        FreeUI_GeneralFragmentDialog freeU_generalFragmentDialog = new FreeUI_GeneralFragmentDialog();
        View view = LayoutInflater.from(context.getApplicationContext()).inflate(R.layout.new_dialog_trackout, null);
        TextView tvaMatCount2 = view.findViewById(R.id.tvaMatCount2);
        TextView tvtMatCount2 = view.findViewById(R.id.tvtMatCount2);
        if (tMatCount==0){
            tvaMatCount2.setText("");
            tvtMatCount2.setText("");
        }else {
            tvaMatCount2.setText(aMatCount+"");
            tvtMatCount2.setText(tMatCount+"");
        }

        TextView tvLotID = view.findViewById(R.id.tvLotID);
        TextView tvScrapNum = view.findViewById(R.id.tvScrapNum);
        TextView tvTotalNum = view.findViewById(R.id.tvTotalNum);
        tvScrapNum.setText(scrapNum);
        tvLotID.setText(lotID);
        TextView tvStep = view.findViewById(R.id.tvStep);
        tvStep.setText(lotInfoEntity.getLOT().getSTEPNAME() + "/" + lotInfoEntity.getLOT().getSTEPDESC());
        TextView tvEqpID = view.findViewById(R.id.tvEqpID);
        tvEqpID.setText(eqpWork);
        TextView tvTrackInQTY = view.findViewById(R.id.tvTrackInQTY);
        tvTrackInQTY.setText(subqty);
        TextView tvTrackOutQTY = view.findViewById(R.id.tvTrackOutQTY);
        int mSubqty = Integer.parseInt(subqty);
        int scrapInt = Integer.parseInt(scrapNum.equals("") ? "0" : scrapNum);

        TextView tvDefect = view.findViewById(R.id.tvDefect);
        NumberFormat numberFormat = NumberFormat.getInstance();
        numberFormat.setMaximumFractionDigits(2);
        int sumDefect = 0;
        if (defectData != null) {
            for (ScrapEntity entity : defectData) {
                if (!entity.getACTIONREASON().contains("不记录良率")) {
                    sumDefect += Integer.parseInt(entity.getMAINQTY().equals("") ? "0" : entity.getMAINQTY());
                }
            }
        } else {
            sumDefect += 0;
        }
        tvTrackOutQTY.setText(String.valueOf(mSubqty - sumDefect - scrapInt));

        BigDecimal b2 = new BigDecimal(Double.toString(mSubqty));
        BigDecimal b1 = new BigDecimal(Double.toString(Integer.parseInt(tvTrackOutQTY.getText().toString())));
        double v1 = b1.divide(b2, 5, BigDecimal.ROUND_HALF_UP).doubleValue();
        double v2 = v1 * 100;
        tvDefect.setText(v2 + "%");

        TextView tvCancel = view.findViewById(R.id.tvCancel);
        TextView tvConfirm = view.findViewById(R.id.tvConfirm);
        tvCancel.setOnClickListener(view1 -> {
            freeU_generalFragmentDialog.dismiss();
        });
        tvConfirm.setOnClickListener(v -> {
            FreeUI_EntityCallBack<BaseResponseBean<LotInfoEntity>> callBack = new CustomDialogEntityCallBack<BaseResponseBean<LotInfoEntity>>
                    (new TypeToken<BaseResponseBean<LotInfoEntity>>() {
                    }.getType(), fragmentManager, context) {

                @Override
                public void onSuccess(Response<BaseResponseBean<LotInfoEntity>> response) {
                    super.onSuccess(response);
                    if (response.body().isSuccess(context, false, fragmentManager)) {
                        String holdstate = response.body().getResponse().getBody().getLOTLIST().get(0).getHOLDSTATE();
                        FreeApi_DialogUtils.getConfirmDialog(context, "确定", holdstate.equals("On") ? "该批次良率超标！" : "出站成功", () -> {
                            callback.onSuccess("");
                        }).show(fragmentManager, "CONFIRM_DIALOG");
                    }
                }

                @Override
                public void onError(Response<BaseResponseBean<LotInfoEntity>> response) {
                    super.onError(response);
                    FreeApi_LogUtils.saveErrorMessages(response.getException(), "LOTTRACKOUT");
                    FreeApi_ToastUtils.showFreeToast("连接服务器失败", context, false, 0);
                }
            };
            JsonObject map = new JsonObject();

            String messageName = "IF.LOTTRACKOUT";
            String actiontype = "DefaultTrackOut";

            switch (method) {
                case "MULTIDEVICELOTTRACKOUT":
                    map.addProperty("TYPE", "1");
                    break;
                case "MultiMasterTrackOut":
                case "Common":
                    messageName = "IF.MULTIMASTERLOTTRACKOUT";
                    actiontype = "MultiMasterTrackOut";
                    break;
            }
            if (activity != null && activity.equals("MultiEqpTrackOutActivity")) {
                map.addProperty("TYPE", "0");
                map.addProperty("TRACK_OUT_QTY", TRACKOUTQTY);
            }
            map.addProperty("ACTIONTYPE", actiontype);
            map.addProperty("EQUIPMENTID", eqpWork);
            map.addProperty("THINNINGTHICKNESS", thinning);
            map.addProperty("OUTOVERTOTALNUMBER", totalNumber);
            map.addProperty("CARRIERACTION", "");
            map.addProperty("DURABLE", "");
            map.addProperty("ALLREWORKFLAG", "N");
            map.addProperty("WAREHOUSEID", scrapNum);
            map.addProperty("STORAGEID", storageid);
            map.addProperty("SPC2", lotInfoEntity.getPART().getSPEC2());
            map.addProperty("aMatCount", tvaMatCount2.getText().toString());
            map.addProperty("CARRIERCASE", lotInfoEntity.getCARRIERCASE());// 黑箱（载具）信息
            List<LotLists> lotList = new ArrayList<>();
            List<LotactionLists> lotactionList = new ArrayList<>();
            LotLists lotList1 = new LotLists(lotID, scan.equals("") ? lotInfoEntity.getLOT().getMAINQTY() : scan);
            lotList.add(lotList1);
            if (scrapListAdapter.getData() != null) {
                for (ScrapEntity mDefectData : scrapListAdapter.getData()) {
                    ArrayList<LotactionLists.QTYList> qtyList = new ArrayList<>();
                    LotactionLists.QTYList qtybean = new LotactionLists.QTYList();

                    qtybean.setSUBQTY("0");
                    qtybean.setMAINQTY(mDefectData.getMAINQTY());
                    qtyList.add(qtybean);

                    if (!(mDefectData.getMAINQTY().equals("0"))){

                        LotactionLists lotactionLists1 = new LotactionLists();
                        lotactionLists1.setLOTID(lotID);
                        lotactionLists1.setACTIONCODE(mDefectData.getACTIONCODE());
                        lotactionLists1.setACTIONREASON(mDefectData.getACTIONREASON());
                        lotactionLists1.setACTIONTYPE("Scrap");
                        lotactionLists1.setSUBQTY(mDefectData.getSUBQTY());
                        lotactionLists1.setMAINQTY(mDefectData.getScrapNum());
                        lotactionLists1.setQTYLIST(qtyList);
                        lotactionList.add(lotactionLists1);
                    }
                }
            }

            map.add("LOTLIST", new JsonParser().parse(new Gson().toJson(lotList)).getAsJsonArray());//传批次集合
            map.add("LOTACTIONLIST", new JsonParser().parse(new Gson().toJson(lotactionList)).getAsJsonArray());
            map.add("DURABLEIDLIST", new JsonParser().parse(new Gson().toJson(carrierList)).getAsJsonArray());
            if (edcList != null) {
                map.add("EDCLIST", new JsonParser().parse(new Gson().toJson(edcList)).getAsJsonArray());
            }
            NetUtils.requestPostNet(messageName, method, context, map, callBack);
            freeU_generalFragmentDialog.dismiss();
        });

        freeU_generalFragmentDialog.setLayout(view);
        freeU_generalFragmentDialog.show(fragmentManager, "SUBMIT_DIALOG");

    }



}
